package com.explorati.interview.interview.chapterfive;

public class ArrayCopy {

	public static void main(String[] args) {
		int[] arr1 = new int[] { 1, 2, 3 };
		int[] arr2 = arr1;
		// 修改arr2同时也修改了arr1，因为指向同一个地址
		arr2[2] = 7;
		for (int i : arr1) {
			System.out.print(i + "\t");
		}

		System.out.println();
		System.out.println("=========深拷贝===========");
		int[] arr4 = new int[] { 1, 2, 3 };
		int[] arr3 = new int[3];
		System.arraycopy(arr4, 0, arr3, 0, arr1.length);
		arr3[2] = 7;
		for (int i : arr4) {
			System.out.print(i + "\t");
		}
	}
}
